package tank.draw;

/**
 * @Author: WaveKing
 * @Description: TODO
 * @Date: Created in 19:52 2023/11/16
 * @Modified By:
 */
public class bullet implements Runnable{
    int x;
    int y;
    int direct;
    int speed = 10;
    Boolean isLive = true;

    public bullet(int x, int y, int direct) {
        this.x = x;
        this.y = y;
        this.direct = direct;
    }

    @Override
    public void run() {
        while (true){
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            switch (direct){
                case 0:
                    y-=speed;
                    break;
                case 1:
                    x+=speed;
                    break;
                case 2:
                    y+=speed;
                    break;
                case 3:
                    x-=speed;
                    break;
            }
            System.out.println("子弹坐标:"+x+"  "+y);
            if (!(x>=0 && x<=1000 && y>=0 && y<=750 && isLive)){
                isLive = false;
                break;
            }
        }
    }
}
